package com.aliance.soo.board.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import com.aliance.soo.board.mapper.BoardMapper;
import com.aliance.soo.board.vo.BoardVo;

public class BoardDao {
	
	private SqlSessionFactory sqlSessionFactory = com.aliance.soo.custom.db.MyBatisManager.getSqlSession();
	
	private static final class BoardDaoHolder {
		static final BoardDao boardDao = new BoardDao();
	}
	
	private BoardDao() {
		
	}
	
	public static BoardDao getInstance() {
		System.out.println("00000000");
		return BoardDaoHolder.boardDao;
	}
	
	public List<BoardVo> getBoardList(Map<String, Object> map) {
		System.out.println("1111111111111111111");
		SqlSession myBatisSession = sqlSessionFactory.openSession();
		System.out.println("22222222222222222222222");
		List<BoardVo> list = null;
		try {
			System.out.println("33333333333333333333");
			BoardMapper mepper = (BoardMapper)myBatisSession.getMapper(BoardMapper.class);
			System.out.println("44444444444444444444444");
			list = mepper.getBoardList(map);
			System.out.println("55555555555555555555555");
			
		} catch (Exception e) {
			System.out.println("000000000000000000000");
		} finally {
			myBatisSession.close();
		}
		return list;
	}

}
